from multiprocessing import freeze_support

from plotting.drawer import plot_gantt_chart
from solution_methods.HHO.run_HHO import run_HHO
from solution_methods.HHO.src.initialization import initialize_run
from solution_methods.helper_functions import load_job_shop_env, load_parameters

if __name__ == '__main__':
    freeze_support()

    # HHO算法
    parameters = load_parameters("configs/HHO.toml")
    jobShopEnv = load_job_shop_env(parameters['instance'].get('problem_instance'))

    population, toolbox, stats, hof = initialize_run(jobShopEnv, **parameters)
    # population.append(jobShopEnv.operations_machine_num)
    makespan, jobShopEnv = run_HHO(jobShopEnv, population, toolbox, stats, hof, **parameters)

    print("HHO算法，最小化最大完工时间——makespan:" + str(makespan))

    plot_gantt_chart(jobShopEnv)
